mui.init();
var my_phone = localStorage.getItem("my_phone");
var user_id = localStorage.getItem("user_id");
var mask = mui.createMask(); //遮罩层
//mui('body').on('tap', '.mui-navigate-right', function() {
//	window.top.location.href = this.href;
//});
mui.back = function() {
	window.top.location.href = '../my/my_user.html';
}
mui('body').on('tap', '#applicant_operator', function() {
	mui.ajax(user_url + '/api/isOperatorUpgrade', {
		data: {
			'sign': "string",
			'user_id': user_id
		},
		dataType: 'json', //服务器返回json格式数据
		type: 'post', //HTTP请求类型
		timeout: 10000, //超时时间设置为10秒；
		contentType: "application/json;charset=UTF-8",
		success: function(data) {
			if(data.code == 10000) {
				//				console.log(JSON.stringify(data.resp))
				if(!data.resp) {
					mui.openWindow({
						url: "applicant_operator.html",
						createNew: true
					});
				} else {
					mui.alert("申请提交成功，等待审核！");
				}
			} else {
				mui.alert(data.msg)
			}
		},
		error: function(xhr, type, errorThrown) {
			//异常处理；
			console.log(type);
		}
	})

});

$(function() {
	mui.ajax(user_url + '/api/userinfo', {
		data: {
			'phone': my_phone,
			'sign': "string",
			'user_id': user_id
		},
		dataType: 'json', //服务器返回json格式数据
		type: 'post', //HTTP请求类型
		timeout: 10000, //超时时间设置为10秒；
		contentType: "application/json;charset=UTF-8",
		success: function(data) {
			//			console.log(JSON.stringify(data.resp.operator_id))
			if(data.code == 10000) {
				var html = "";
				html += '<a href="javascript:;">';
				html += '<img class="mui-media-object mui-pull-left" src="../../images/personal.png">';
				html += '<div class="mui-media-body">';
				html += '<span class="tel">' + my_phone + '</span>';
				if(!data.resp.operatorString) {
					html += '<p class="mui-ellipsis my_user_btn tels">无运营商等级</p>';
				} else {
					html += '<p class="mui-ellipsis my_user_btn tels">' + data.resp.operatorString + '</p>';
				}
				html += '</div>';
				html += '</a>';
				$("#list").append(html);
			}
		},
		error: function(xhr, type, errorThrown) {
			//异常处理；
			console.log(type);
		}
	})
})
window.addEventListener('refresh_method', function(e) { //执行刷新
	location.reload();
});
window.onload = function() {
	mui.plusReady(function() {
		var self = plus.webview.currentWebview();
		plus.nativeUI.closeWaiting(); //关闭等待
	});
}